import { getCars } from '@/api/car'
import { Message } from 'element-ui'


const carsOptions = {
    namespaced: true,
    actions: {
        // 获取停车场车辆列表数据
        async getCarList(context, id) {
            let result = await getCars(id)
            if (result.code === 200) {
                if (result.data.length === 0) {
                    Message({ type: 'warning', message: result.message })
                }
                context.commit('GETCARLIST', result.data)
            }
        }
    },
    mutations: {
        GETCARLIST(state, data) {
            state.carList = data
        },
        // 清空车辆列表
        CLEARCARLIST(state) {
            state.carList = []
        }
    },
    state: {
        carList: []
    },
    getters: {}
}
export default carsOptions